package service;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;

import pojo.Archive;
import dao.ArchiveDao;
import util.MybatisSessionFactory;
public class ArchiveService {
	SqlSession session=MybatisSessionFactory.getSqlSession();
	ArchiveDao dao=session.getMapper(ArchiveDao.class);
    public void add( 
    		@Param(value="archive_id")String archive_id,
    		@Param(value="identity")String identity,
    		@Param(value="name")String name,
    		@Param(value="gender")String gender,
    		@Param(value="birthday")String birthday,
    		@Param(value="date_retire1")String date_retire1,
    		@Param(value="date_retire2")String date_retire2,
    		@Param(value="sp")String sp,
    		@Param(value="fc")String fc,
    		@Param(value="title")String title,
    		@Param(value="seniority")String seniority
  	        ){
    	    dao.add(archive_id, identity, name, gender, birthday, date_retire1, date_retire2, sp, fc, title, seniority);
    	    session.commit();}
	public List<Archive> queryone(
			@Param(value="search")String search) {
            List<Archive> map=dao.queryone(search);
             return map;	}
	public Archive query(
			@Param("id")String id){
		    Archive map=dao.query(id);
		    return map;    }
	public void update(
			@Param("id")String id,
    		@Param("identity")String identity,
    		@Param("name")String name,
    		@Param("gender")String gender,
    		@Param("birthday")String birthday,
    		@Param("date_retire1")String date_retire1,
    		@Param("date_retire2")String date_retire2,
    		@Param("sp")String sp,
    		@Param("fc")String fc,
    		@Param("title")String title,
    		@Param("seniority")String seniority){
	        dao.update(id, identity, name, gender, birthday, date_retire1, date_retire2, sp, fc, title, seniority);
		    session.commit();
	} 
    public  List<Map> queryword(@Param("archive_id") String archive_id){
    	    List<Map> map=dao.queryword(archive_id);
    	    session.commit();
		    return map;}
    public  List<Map> querydel(@Param("archive_id") String archive_id){
	        List<Map> map=dao.querydel(archive_id);
	        session.commit();
	        return map;}
    public void deletephoto(@Param("id") String id){
		    dao.deletephoto(id);
		    session.commit();
	}
    public List<Map>querymohu(
    		String id,String archive_id,String identity,String name,String gender,
    	    String birthday,String date_retire1,String date_retire2,String sp,String fc,
    		String title,String seniority){
		    List<Map> map=dao.querymohu(id, archive_id, identity, name, gender, birthday, date_retire1, date_retire2, sp, fc, title, seniority);
		    session.commit();
		    return map;
 }
    public Map<String ,Object> lastid(){
    	    Map<String ,Object> map=dao.lastid();
    	    session.commit();
		    return map;
    }
    public List<Map>querylist(String userId){
    	    List<Map> map=dao.querylist(userId);
    	    session.commit();
		    return map;
    }
    public List<Map>querylistadd(String userId){
    	    List<Map> map=dao.querylistadd(userId);
    	    session.commit();
		    return map;
    }
    public List<Map> querycount(
    		                    @Param("date1") String date1,
                                @Param("date2") String date2) {
		 return dao.querycount(date1,date2);
	}

}
